module Main where

import Data.List
import System

-- revAndSort reads a file, creates a reversed and a sorted
-- version of that file, and returns the number of characters
-- in the file
revAndSort :: FilePath -> IO Int
revAndSort file =
  do s <- readFile file
     writeFile ("reversed-" ++ file) (reverse s)
     writeFile ("sorted-" ++ file) (sort s)
     return (length s)

-- main runs revAndSort on all arguments given on the
-- command line
main :: IO ()
main =
  do args <- getArgs
     sequence_ [ revAndSort file | file <- args ]
